Repository navigation
fix(aggregator): validate chargesAttention before confirming surfaced keys (#3681) - #4299
Conversation
… keys (#3681) confirm-charges-surfaced.ts runs after delivery and passed each parsed chargesAttention element straight to unmatchedKey. A malformed element crashed confirmation with a raw TypeError (so delivered charges re-alerted forever and valid siblings were never confirmed), a missing normalized silently persisted an undefined|... key, and a non-object top-level feed either raw-threw or was silently accepted. - Reject a non-object top-level feed with a clear invalid-feed error. - Validate each element before keying (string normalized, finite numeric amountUsd, string at); drop malformed elements with a loud stderr count while still confirming well-formed siblings. - unmatchedKey now takes Pick<UnmatchedCharge, normalized|amountUsd|at> (type-only widening of what it actually reads). - Regression tests for all seven cases run the real script as a subprocess against an isolated surfaced-state path.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 38 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Fixes #3681 (queue task 6168).
confirm-charges-surfaced.tsruns after delivery (frompush-fleet-feed.sh) and passed each parsedchargesAttentionelement straight tounmatchedKey. On current main the triage reproduction showed:[null], a string amount, and mixed[valid, null]all exit 1 with raw TypeErrors and no state write (the valid sibling's confirmation is lost, so delivered charges re-alert forever); top-levelnullraw-throws; top-level[]exits 0 silently; an element missingnormalizedexits 0 and persistsundefined|12.50|2026-10-30.Change
invalid feed: expected a JSON objecterror — never a raw TypeError, never silent success.normalized, finite numericamountUsd, stringat(checked with the sharedsrc/validate.tsprimitives). Malformed elements are dropped with a loud stderr count (confirm-charges-surfaced: dropped N malformed chargesAttention element(s)); well-formed siblings are still confirmed.unmatchedKeynow takesPick<UnmatchedCharge, "normalized" | "amountUsd" | "at">— a type-only widening to exactly the fields it reads; no behavior change for existing callers.push-fleet-feed.shsequencing (fix(aggregator): charges surfaced keys are persisted before feed delivery, so a failed transfer permanently suppresses the flags (PR #2149) #3122), no render-path changes (aggregator(feed): charge gates accept negative/zero amounts and non-date 'at' — isChargeRow and isUnmatchedCharge pass rows no producer can emit, falsifying the charges total and attention-flag severity #3458), no collector output changes.Tests
test/confirm-charges-surfaced-3681.test.tsruns the real script as a subprocess against an isolated surfaced-state path for all seven cases (valid control, null element, string amount, mixed valid+invalid, top-level null, top-level array, missing normalized): 7/7 pass.charges-collect,charges-feed-gate,charges-push,feed): 63/63 pass.tsc --noEmit: no errors in the touched files (pre-existing errors elsewhere on main are unchanged).Need help on this PR? Tag
@codesmith-botwith what you need.